<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('订单详细')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form id="form-order-export" class="form-horizontal">
        <input type="hidden" name="orderProcess" th:value="${orderProcess}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>订单类型：</label>
            <div class="col-sm-6">
                <select name="orderType" class="form-control m-b" th:with="type=${@dict.getType('order_type')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                            th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group" id="orderTypeLinkBox">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>外协类型：</label>
            <div class="col-sm-6">
                <select name="outSourceType" class="form-control m-b">
                    <option value="2">外部协作</option>
                    <option value="1">内部协作</option>
                </select>
            </div>
        </div>
        <div class="form-group" id="outSourceLinkBox">
            <label class="col-sm-3 control-label">委托公司：</label>
            <div class="col-sm-6">
                <div class="input-group">
                    <select name="deptId" class="form-control m-b" required>
                        <option value="0">全部</option>
                        <option th:each="dept:${outSourceCompanyList}" th:text="${dept.name}"
                                th:value="${dept.id}"></option>
                    </select>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>订单日期：</label>
            <div class="col-sm-3">
                <div class="input-group">
                    <input type="text" class="form-control time-input" id="beginTime" placeholder="开始时间"
                           name="params[beginTime]" required/>至
                    <input type="text" class="form-control time-input" id="endTime" placeholder="结束时间"
                           name="params[endTime]" required/>
                </div>
            </div>
        </div>
        <!--<div class="form-group">-->
        <!--<label class="col-sm-3 control-label"><span style="color: red; ">*</span>客户信息：</label>-->
        <!--<div class="col-sm-6">-->
        <!--<div class="input-group">-->
        <!--<input type="text" class="form-control" id="suggest-demo-3">-->
        <!--<div class="input-group-btn">-->
        <!--<button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">-->
        <!--<span class="caret"></span>-->
        <!--</button>-->
        <!--<ul class="dropdown-menu dropdown-menu-right" role="menu">-->
        <!--</ul>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-suggest-js"/>
<script th:inline="javascript">
    var prefix = ctx + "oa/order";
    $('#orderTypeLinkBox').hide();
    $('#outSourceLinkBox').hide();
    //订单类型改变时间
    $("select[name='orderType']").select2().on("change", function () {
        if ($(this).val() == 1) {
            $('#orderTypeLinkBox').show();
        } else {
            $('#orderTypeLinkBox').hide();
        }
    });
    $("select[name='outSourceType']").select2().on("change", function () {
        if ($(this).val() == 1) {
            $('#outSourceLinkBox').show();
        } else {
            $('#outSourceLinkBox').hide();
        }
    });

    //选择外协公司
    $("#chooseOutSourceCompany").bsSuggest({
        indexId: 1,
        indexKey: 0,
        keyField: "companyName",
        hideOnSelect: true,
        effectiveFields: ["companyName"],
        effectiveFieldsAlias: {
            id: "编号",
            companyName: "公司名"
        },
        inputWarnColor: '',
        data: {
            'value': (function () {
                var list = '';    // 先定义个值，方便下面赋值
                $.ajax({
                    type: 'get',
                    url: ctx + "back/outsourceCompany/listForSelect",
                    dataType: 'json',
                    async: false,
                    success: function (result) {
                        if (result.code == web_status.SUCCESS) {
                            list = result.data;
                        } else {
                            $.modal.alert(result.msg);
                        }
                    }
                });
                return list;
            })()
        }
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.modal.confirm("确认按此筛选导出订单吗？", function () {
                var data = $("#form-order-export").serialize();
                $.modal.loading("正在导出数据，请稍后...");
                $.post(ctx + "back/order/exportCustom", data, function (result) {
                    if (result.code == web_status.SUCCESS) {
                        window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                    } else if (result.code == web_status.WARNING) {
                        $.modal.alertWarning(result.msg)
                    } else {
                        $.modal.alertError(result.msg);
                    }
                    $.modal.closeLoading();
                });
            });
        }
    }
</script>
</body>
</html>